<template>
	<view class="com-box" :style="{ paddingTop: safeAreaInsets.top + 15 + 'px' }">
			<view class="com-head">
				<view class="com-head-back" v-if="isShowBackBtn" @click="navClickBack">
					<image class="img" src="@/static/images/allow-left.png" mode=""></image>
				</view>
				<image class="com-head-logo" src="@/static/images/logo2.png" mode=""></image>
			</view>
		</view>
</template>

<script setup>
	import { ref } from 'vue'
	
	let props = defineProps({
		isShowBackBtn: {
			type: Boolean,
			default: true
		}
	})
	
	
	// 获取手机头部到内容的安全距离
	let { safeAreaInsets } = uni.getSystemInfoSync()
	
	// 点击返回按钮
	let navClickBack = () => {
		// 如果存在上一个页面，就返回上一个页面，没有就返回首页
		let pages = getCurrentPages();
		if (pages.length == 1) {  
			uni.switchTab({
				url: '/pages/index/index',  
			})  
		} else {  
			uni.navigateBack({
				delta: 1  
			});
		}
	}
	
</script>

<style lang="scss">
.com-box{
	padding-bottom: 40rpx;
	
	.com-head{
		padding-left: 30rpx;
		display: flex;
		align-items: center;
		position: relative;
		height: 21rpx;
		
		.com-head-back{
			.img{
				width: 15rpx;
				height: 28rpx;
			}
		}
		
		.com-head-logo{
			width: 186rpx;
			height: 36rpx;
			position: absolute;
			left: 50%;
			transform: translateX(-50%);
		}
	}
}

</style>